package com.yhty.web.action;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.yhty.model.User;
import com.yhty.service.AuthManager;

/**
 * 登陆action
 * @author roy
 * 2011-3-2-下午01:08:02
 */
@Controller("mainAction")
@RequestMapping("/main")
public class MainAction {
	private AuthManager authManager;

	@RequestMapping(value="/login",method = RequestMethod.POST)
	public String login(User user,Model model,HttpSession session){
		if(authManager.isAuthed(user)){
			session.setAttribute("user", user);
			return "main";
		}
		return "login";
	}
	
	@RequestMapping(value="/in")
	public String in(){
		return "login";
	}

	@Autowired
	public void setAuthManager(AuthManager authManager) {
		this.authManager = authManager;
	}
}
